<template>
  <!--公用组件 -->
  <div class="foodDetail-container">
    <van-nav-bar class="bgcolor" safe-area-inset-top @click-left="back">
      <template #left>
        <van-icon class="leftIcon" name="arrow-left" size="18" />
      </template>
    </van-nav-bar>

    <div class="main-content">
      <div class="food-face">
        <div class="face">
          <van-image :src="this.food.face" fit="cover" />
        </div>
        <div class="food-name">
          <span>{{ food.name }}</span>
        </div>
      </div>

      <div class="food-function">
        <span>功效：{{ food.functions }}</span>
      </div>

      <div class="food-make">
        <div class="title">
          <span>做法</span>
        </div>

        <div class="make-content" v-html="food.make"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { getFoodInfo } from "@/api/food";
export default {
  name: "Fooddetail",

  data() {
    return {
      food: {
        affectCate: null,
        face: "",
        foodCate: null,
        functions: "",
        id: 0,
        make: "",
        name: "",
        personCate: null,
      },
    };
  },

  mounted() {},

  activated() {
    let params = {
      foodId: this.$route.params.foodId,
    };
    getFoodInfo(params).then((res) => {
      this.food = res.data;
    });
  },

  methods: {
    back() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="less" scoped>
.foodDetail-container {
  min-height: 100%;
  height: auto;
  background-image: url("../assets/images/myplanbg.png");
  background-size: cover;
  .bgcolor {
    background-color: rgb(153, 217, 157);
    color: #000;
    .leftIcon {
      color: #000;
    }
  }

  .main-content {
    width: 335px;
    height: auto;
    margin: 0 auto;

    .food-face {
      width: 150px;
      height: auto;
      padding: 10px 0;
      margin: 0 auto;

      .face {
        width: 150px;
        height: 150px;
        border-radius: 15px;
        overflow: hidden;

        .van-image {
          width: 150px;
          height: 150px;
        }
      }

      .food-name {
        width: 100%;
        height: 22px;
        padding: 15px 0;
        span {
          display: inline-block;
          width: 100%;
          line-height: 22px;
          text-align: center;
          font-size: 18px;
        }
      }
    }

    .food-function {
      box-sizing: border-box;
      width: 285px;
      height: auto;
      padding: 0 5px 0 5px;
      margin: 0 auto;
      background-color: #bcebc7;

      span {
        display: inline-block;
        width: 100%;
        line-height: 28px;
        text-align: left;
        font-size: 15px;
      }
    }

    .food-make {
      box-sizing: border-box;
      width: 280px;
      height: auto;
      padding: 5px 5px;
      margin: 15px auto;
      background-color: #bcebc7;

      .title {
        width: 100%;
        height: 30px;
        span {
          line-height: 30px;
          font-size: 15px;
        }
      }

      .make-content {
        width: 100%;
        height: auto;
      }
    }

    .make-content /deep/ p {
      line-height: 18px;
      font-size: 15px;
    }
  }
}
</style>